<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // ['1','3','5','3','5','3','8','9'] 统计次数 次数最大的次数是谁

    let arr = ['1','3','5','3','5','3','3','9']
    let obj = {}
    arr.forEach(function(item,index){
      obj[item]?obj[item]++ : (obj[item] = 1)
    })
    console.log(obj)


    let max = 0
    let n = 0
    for (let k in obj){
      console.log(obj[k])
      if(max<obj[k]){
        max=obj[k]
        n = k
      }
    }
    // console.log(max,n)
    console.log(`次数最多的是${n}出现${max}次`)
  </script>
</body>
</html>